// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.QueryDsl
{
	public sealed partial class IntervalsPrefix : IIntervalsVariant, IIntervalsQueryVariant
	{
		[JsonInclude]
		[JsonPropertyName("analyzer")]
		public string? Analyzer { get; set; }

		[JsonInclude]
		[JsonPropertyName("prefix")]
		public string Prefix { get; set; }

		[JsonInclude]
		[JsonPropertyName("use_field")]
		public Elastic.Clients.Elasticsearch.Field? UseField { get; set; }
	}

	public sealed partial class IntervalsPrefixDescriptor<TDocument> : SerializableDescriptorBase<IntervalsPrefixDescriptor<TDocument>>
	{
		internal IntervalsPrefixDescriptor(Action<IntervalsPrefixDescriptor<TDocument>> configure) => configure.Invoke(this);
		public IntervalsPrefixDescriptor() : base()
		{
		}

		private string? AnalyzerValue { get; set; }

		private string PrefixValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? UseFieldValue { get; set; }

		public IntervalsPrefixDescriptor<TDocument> Analyzer(string? analyzer)
		{
			AnalyzerValue = analyzer;
			return Self;
		}

		public IntervalsPrefixDescriptor<TDocument> Prefix(string prefix)
		{
			PrefixValue = prefix;
			return Self;
		}

		public IntervalsPrefixDescriptor<TDocument> UseField(Elastic.Clients.Elasticsearch.Field? useField)
		{
			UseFieldValue = useField;
			return Self;
		}

		public IntervalsPrefixDescriptor<TDocument> UseField<TValue>(Expression<Func<TDocument, TValue>> useField)
		{
			UseFieldValue = useField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (!string.IsNullOrEmpty(AnalyzerValue))
			{
				writer.WritePropertyName("analyzer");
				writer.WriteStringValue(AnalyzerValue);
			}

			writer.WritePropertyName("prefix");
			writer.WriteStringValue(PrefixValue);
			if (UseFieldValue is not null)
			{
				writer.WritePropertyName("use_field");
				JsonSerializer.Serialize(writer, UseFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class IntervalsPrefixDescriptor : SerializableDescriptorBase<IntervalsPrefixDescriptor>
	{
		internal IntervalsPrefixDescriptor(Action<IntervalsPrefixDescriptor> configure) => configure.Invoke(this);
		public IntervalsPrefixDescriptor() : base()
		{
		}

		private string? AnalyzerValue { get; set; }

		private string PrefixValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? UseFieldValue { get; set; }

		public IntervalsPrefixDescriptor Analyzer(string? analyzer)
		{
			AnalyzerValue = analyzer;
			return Self;
		}

		public IntervalsPrefixDescriptor Prefix(string prefix)
		{
			PrefixValue = prefix;
			return Self;
		}

		public IntervalsPrefixDescriptor UseField(Elastic.Clients.Elasticsearch.Field? useField)
		{
			UseFieldValue = useField;
			return Self;
		}

		public IntervalsPrefixDescriptor UseField<TDocument, TValue>(Expression<Func<TDocument, TValue>> useField)
		{
			UseFieldValue = useField;
			return Self;
		}

		public IntervalsPrefixDescriptor UseField<TDocument>(Expression<Func<TDocument, object>> useField)
		{
			UseFieldValue = useField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (!string.IsNullOrEmpty(AnalyzerValue))
			{
				writer.WritePropertyName("analyzer");
				writer.WriteStringValue(AnalyzerValue);
			}

			writer.WritePropertyName("prefix");
			writer.WriteStringValue(PrefixValue);
			if (UseFieldValue is not null)
			{
				writer.WritePropertyName("use_field");
				JsonSerializer.Serialize(writer, UseFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}
}